package com.yuchen.ishop.service.seller;

import com.yuchen.ishop.entity.Shop;
import com.yuchen.jaxrs.Responses;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.utils.config.ConfigUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@Service
public class ShopRestClient {

    public Shop get(Long id) {
        String url = ConfigUtils.config.get("sellerShop_get");
        Map map = new HashMap(1);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Shop.class, url);
    }

    public Shop findShopBySellerId(Long sellerId) {
        String url = ConfigUtils.config.get("sellerShop_findShopBySellerId");
        Map map = new HashMap(1);
        map.put("sellerId", sellerId);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Shop.class, url);
    }

    public Shop insertShop(Shop shop) {
        String url = ConfigUtils.config.get("sellerShop_insert");
        return RestClientUtils.post(Shop.class, shop, url);
    }

    public Responses updateShop(Shop shop) {
        String url = ConfigUtils.config.get("sellerShop_update");
        return RestClientUtils.post(Responses.class, shop, url);
    }
}
